import javax.swing.*;

/**
 *  The main class for the <i>SafeTrade</i> application.
 */
public class SafeTrade
{
  public static void main(String[] args)
  {
    StockExchange exchange = new StockExchange();
    exchange.listStock("DS", "DanceStudios.com", 12.33);
    exchange.listStock("NSTL", "Nasty Loops Inc.", 0.25);
    exchange.listStock("GGGL", "Giggle.com", 10.00);
    exchange.listStock("MATI", "M and A Travel Inc.", 28.20);
    exchange.listStock("DDLC", "Dulce De Leche Corp.", 57.50);
    exchange.listStock("SAFT", "SafeTrade.com Inc.", 322.45);

    Brokerage safeTrade = new Brokerage(exchange);
    safeTrade.addUser("stockman", "sesame");
    safeTrade.login("stockman", "sesame");
    safeTrade.addUser("mstrade", "bigsecret");
    safeTrade.login("mstrade", "bigsecret");

    LoginWindow window = new LoginWindow("Safe Trade", safeTrade);
    window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    window.setBounds(0, 0, 360, 140);
    window.setVisible(true);
    //If these lines don't compile, you didn't go into your Brokerage class
    //and change the traders Map to public!!!
    Trader t1 = safeTrade.traders.get("stockman");
    Trader t2 = safeTrade.traders.get("mstrade");

    //     TradeOrder tradeOrder = new TradeOrder(myTrader, symbol, buyOrder,
    //                                            marketOrder, numShares, price);
    t1.placeOrder(new TradeOrder(t1, "DS", true, false, 100, 11.0));
    t1.placeOrder(new TradeOrder(t1, "DS", true, false, 100, 10.0));
    t1.placeOrder(new TradeOrder(t1, "DS", true, false, 100, 12.0));
    t1.placeOrder(new TradeOrder(t1, "DS", true, true, 25, 0.0));
    t1.placeOrder(new TradeOrder(t1, "DS", true, true, 50, 0.0));
    t1.placeOrder(new TradeOrder(t1, "DS", true, true, 100, 0.0));
    
    t2.placeOrder(new TradeOrder(t2, "DS", false, false, 100, 13.0));
    System.out.println(exchange.getQuote("DS"));
    t2.placeOrder(new TradeOrder(t2, "DS", false, false, 100, 14.0));
    System.out.println(exchange.getQuote("DS"));    
    t2.placeOrder(new TradeOrder(t2, "DS", false, false, 100, 15.0));
    t2.placeOrder(new TradeOrder(t2, "DS", false, false, 100, 14.0));
    t2.placeOrder(new TradeOrder(t2, "DS", false, false, 100, 16.0));
    t2.placeOrder(new TradeOrder(t2, "DS", false, true, 50, 0.0));
    System.out.println(exchange.getQuote("DS"));    
    t2.placeOrder(new TradeOrder(t2, "DS", false, true, 75, 0.0));
    System.out.println(exchange.getQuote("DS"));    
    t2.placeOrder(new TradeOrder(t2, "DS", false, true, 100, 0.0));
    System.out.println(exchange.getQuote("DS")); 
  }
}
